/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * OperationFrame.java
 *
 * Created on 27/11/2011, 00:21:14
 */
package proj5labbd.graphics.abstractOpGraphics;

import javax.swing.JPanel;
import proj5labbd.graphics.MainFrame;

/*
 * Classe abstrata utilizada nos frames de operações DML ("SELECT","INSERT","UPDATE",""REMOVE")
 */
public class OperationFrame extends javax.swing.JFrame {

    protected MainFrame frame;
    protected OperationPanel insertPanel;
    protected OperationPanel viewPanel;
    protected OperationPanel rmPanel;
    protected OperationPanel updatePanel;
    protected OperationPanel consultaPanel;
    protected static enum OpPanel { INSERT, VIEW, REMOVE, UPDATE, CONSULTA } 
    /** Creates new form OperationFrame */
    public OperationFrame(MainFrame frame) {
        initComponents();
        this.frame = frame;
        this.setResizable(false);
        
    }
    
    //adiciona painel no frame
    public void addPanel(OperationPanel panel, OpPanel OP) {
        if (OP == OpPanel.INSERT) {
            this.insertPanel = panel;
        }
        if (OP == OpPanel.REMOVE) {
            this.rmPanel = panel;
        }
        if (OP == OpPanel.UPDATE) {
            this.updatePanel = panel;
        }
        if (OP == OpPanel.VIEW) {
            this.viewPanel = panel;
        }
        if (OP == OpPanel.CONSULTA) {
            this.consultaPanel = panel;
        }
    }
    
    public OperationPanel getInsertPanel() {
        return insertPanel;
    }
    
    public OperationPanel getViewPanel() {
        return viewPanel;
    }
    
    public OperationPanel getRmPanel() {
        return rmPanel;
    }
    
    public OperationPanel getUpdatePanel() {
        return updatePanel;
    }
    
    public OperationPanel getConsultaPanel() {
        return consultaPanel;
    }
    
    public void setInsertPanel(OperationPanel panel) {
        this.insertPanel = panel;
    }
    
    public void setViewPanel(OperationPanel panel) {
        this.insertPanel = panel;
    }
    
    public void setRmPanel(OperationPanel panel) {
        this.rmPanel = panel;
    }
    
    public void setUpdatePanel(OperationPanel panel){
        this.updatePanel = panel;
    }

    public void setConsultaPanel(OperationPanel panel){
        this.consultaPanel = panel;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jtbbOperation = new javax.swing.JTabbedPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jtbbOperation, javax.swing.GroupLayout.DEFAULT_SIZE, 589, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jtbbOperation, javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    protected javax.swing.JTabbedPane jtbbOperation;
    // End of variables declaration//GEN-END:variables
    public void printException(Exception ex) {
        frame.printException(ex);
    }
    public void printPrompt(String e) {
        frame.printPrompt(e);
    }
}
